import { type MockMethod } from 'vite-plugin-mock'

import userRouter from './routers.json'
// console.log('导入:userRouter :', userRouter)

export default [
  {
    url: '/api/user/get',
    method: 'get',

    response: ({ query }: { query: any }) => {
      console.log('query :', query)
      return {
        'array|10': [
          {
            name: '@cfirst()@cname()',
            desc: '@csentence(5)',
            birthday: "@date('yyyy-MM-dd')",
            age: '@integer(18, 60)',
            address: '@county(true)',
          },
        ],
        query: query,
      }
    },
  },
  {
    url: '/api/user/page',
    method: 'get',

    response: ({ query: { current, size } }: { query: { current: number; size: number } }) => {
      return {
        'array|10': [
          {
            name: `@cfirst()@cname()${current}`,
            desc: '@csentence(5)',
            birthday: "@date('yyyy-MM-dd')",
            age: '@integer(18, 60)',
            address: '@county(true)',
          },
        ],
      }
    },
  },

  // 用户身份
  {
    url: '/api/user/info',
    method: 'get',

    response: ({ query }: { query: any }) => {
      return {
        name: 'admin',
        role: 'admin',
      }
    },
  },

  {
    url: '/api/user/getRouters',
    method: 'get',
    response: ({ query }: { query: any }) => {
      console.log('query :', query)
      return userRouter
    },
  },
] as MockMethod[]
